<template>
  <el-dialog width="500px" title="添加用户邮箱" :visible.sync="dialogVisible" :close-on-click-modal="false">
    <el-form ref="ruleForm" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="用户邮箱" prop="user_email">
        <el-input v-model="form.user_email" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="dialogVisible = false">取 消</el-button>
      <el-button size="small" type="primary" @click="submit">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { setOrderRemark } from '@/api/order'
export default {
  // props: ['orderId'],
  props: {
    orderId: {
      type: String,
      default: ''
    },
    dialogTitle:{
      type: String,
      default: ''
    }
  },
  data() {
    return {
      form: {
				orderId:'',
        user_email: ''
      },
      rules: {
        user_email: [
				{ required: true, message: '请输入邮箱地址', trigger: 'blur' },
				{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
        ]
      },
      dialogVisible: false
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.form.orderId = this.orderId
        this.form.user_email = ''
      } else {
        this.$refs['ruleForm'].resetFields()
      }
    }
  },
  methods: {
    submit() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          // setOrderRemark({ ...this.form }).then(res => {
          //   this.dialogVisible = false
          //   this.$emit('getList', true)
          // })
        } else {
          this.$message({
            message: '请检查表单错误',
            type: 'error'
          })
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
